import config
import os


def check_input(input):
    if input.isdigit():
        return True
    return False

def player_choice():
    player_input = raw_input('Choose: ')
    if check_input(player_input):
        return player_input
    raise Exception("Not correct options")

def main(config):
    os.system('clear')
    print "Welcome to " + config.title + " \"CLI Edition\""
    print
    print "Please choose a game to play"
    print
    for game_option in config.enabled_games:
        print game_option['id'], ') ' + game_option['title']
    try:
        player_selection = player_choice()
        game = config.game_factory(player_selection)
        game.start()
    except Exception as e:
        print "Error", e
        return

if __name__ == '__main__':
    main(config)
